package cn.hinglo.permission.controller;


import cn.hinglo.baseservice.base.BaseController;
import cn.hinglo.common.entity.Result;
import cn.hinglo.permission.bean.Permission;
import cn.hinglo.permission.service.PermissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author HingLo
 * @createTime: 2019-04-29 12:18:27
 * @description: PermissionController 控制器
 */
@Slf4j
@RestController
@RequestMapping("/permission")
public class PermissionController extends BaseController {

    @Autowired
    private PermissionService permissionService;


    /**
     * Permission列表
     */
    @GetMapping("list")
    public Result list(Integer page, Integer size) {
        return success(permissionService.listPermissionService(getPage(page), getSize(size)));
    }

    /***
     * 添加Permission 对象
     * @param permission 添加的Permission对象
     */
    @PostMapping("add")
    public Result add(Permission permission) {
        return success(permissionService.addPermissionService(permission));
    }

    /***
     * 删除指定Id的Permission对象
     * @param id Permission编号
     */
    @PostMapping("delete")
    public Result delete(Integer id) {
        return success(permissionService.deletePermissionService(id));
    }

}